<!DOCTYPE html>
<html>
  <head>
    <title>设备交接清单</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  </head>


<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="../css/style.css"/>
<!-- 插件样式 -->
<link rel="stylesheet" type="text/css" href="./css/sm.css">
<link rel="stylesheet" type="text/css" href="./css/sm-extend.css">

<link rel="stylesheet" type="text/css" href="../css/weui/example.css">
<link rel="stylesheet" type="text/css" href="../css/weui/weui.css" />

<script src="../js/jquery-2.1.1.js"></script>

<!-- 插件js -->
<script src="./js/zepto.js"></script>
<script src="./js/sm.js" ></script>
<script src="./js/sm-extend.js" ></script>

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="../js/min/modernizr-custom-v2.7.1.min.js"></script>
<script src="../js/min/hammer-v2.0.3.min.js" ></script>
<script src="../js/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
<script src="../js/common.js"></script>
<script type="text/javascript">
	window.$$=window.Zepto = Zepto;
</script>
<body>
	<header class="bar bar-nav">
	    <a class="button button-link button-nav pull-left" href="javaScript:history.go(-1)" data-transition="slide-out">
	      <span class="icon icon-left"></span>
	      返回
	    </a>
	    <a class="button button-link button-nav pull-right" href="" id="addBtn">十&nbsp;&nbsp;</a>
	    <h1 class="title">交接单</h1>
	  </header>
<div class="content" style="top: 0.5rem;">
  <div class="list-block">
    <ul id="info_list" style="padding: 8px;">
    </ul>
  </div>
</div>

<script type="text/javascript">
var listType = $.getUrlParam("listType")||"0";	//0:软件  1:硬件
var transferType = $.getUrlParam("transferType")||"0";	//交接类型   0:租客交接清单 1:业主交接清单
var userId = $.getUrlParam("userId");
$(function(){
	loadTransferList();	
	if(listType=="0"){
		$("#addBtn").attr("href", "./ruanjianqingdanAdd.html?transferType="+transferType+"&userId="+userId+"&type=1");
	}else{
		$("#addBtn").attr("href", "./yingjianqingdanAdd.html?transferType="+transferType+"&userId="+userId+"&type=2");
	}
})

function loadTransferList(){
	$$.showPreloader("加载中");
	$.ajax({
		url : "../houseTransferList/getList.do",
		data : {
			userIdFlag: (userId?"":"1"),
			userId: userId||"",
			transferType: transferType,	//交接类型   0:租客交接清单 1:业主交接清单
			listType: listType,
			pageSize: 50,
			pageNumber: 1
		},
		type : "GET",
		dataType : 'json',
		cache : false,
		success : function(ret){
			$$.hidePreloader();
			var html = '';
			if(ret.rows && ret.rows.length>0){
				$.each(ret.rows,function(i,n){
				    html += "<li class=\"item-content \"  style=\"display: contents;text-align: center;padding-left: 5px\" >"+n.listName;
					html += "<div class=\"item-after\" style=\"float: right;\"></div>";
					html += " <div class=\"operate-btn\">";
					if(n.listType==0){
						html += "<span id=\"edit-btn\" class=\"edit-btn\" style=\"padding-left: 40px;\" onclick=\"toLink('./ruanjianqingdanAdd.html?transferType="+n.transferType+"&type="+n.listType+"&houseId="+n.houseId+"&userId="+n.userId+"&transferId="+n.transferId+"')\">修改</span>";
					}else{
						html += "<span id=\"edit-btn\" class=\"edit-btn\" style=\"padding-left: 40px;\" onclick=\"toLink('./yingjianqingdanAdd.html?transferType="+n.transferType+"&type="+n.listType+"&houseId="+n.houseId+"&userId="+n.userId+"&transferId="+n.transferId+"')\">修改</span>";
					}
					
					html += "<span id=\"del-btn\" class=\"del-btn\" style=\"padding-left: 40px;\" onclick=\"toDel('"+n.transferId+"','"+n.listName+"')\">删除</span>";
					html += " </div></li>";
				});
			}
			$("#info_list").html( html||'<li class="item-content item-link">暂无数据</li>' )
		},
		error: function(){

			$$.hidePreloader();
			$$.toast("加载出错");
		}
	});
}


function toLink(txt,tagrt) {
	document.location.href = "./" + txt;
}
function toDel(id , name){
	 $$.confirm('确定删除设备清单【 '+name+" 】",
		        function () {
				$.ajax({
					url : "../houseTransferList/delTransfer.do",
					data : {
						transferId : id
					},
					type : "POST",
					dataType : 'json',
					cache : false,
					success : function(ret){
						console.log(ret);
						loadTransferList();
						$$.toast(ret.msg);	
					},
					error: function(){
						$$.toast('删除失败');	
					}
				}); 
		        },
		        function () {
		          
		        }
		      );
}

</script>
</body>
</html>
